-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
node-api: avoid calling virtual methods in base's dtor #44424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node-api: avoid calling virtual methods in base's dtor #44424
Conversation
|
Review requested:
|
|
Maybe I'm missing something but |
|
src/js_native_api_v8.h
Outdated
| virtual ~napi_env__() { FinalizeAll(); } | ||
| v8::Isolate* const isolate; // Shortcut for context()->GetIsolate() | ||
| v8impl::Persistent<v8::Context> context_persistent; | ||
| virtual ~napi_env__() = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe try if you can make the constructor protected, to avoid callers deleting it without proper cleanup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense to me. Thank you for the suggestion! Updated.
Derived classes' fields are already destroyed if the virtual methods are invoked in the base class's destructor. It is not safe to call virtual methods in base's dtor.
e2d1c39 to
dd48302
Compare
|
Landed in ad3c7bc |
Derived classes' fields are already destroyed if the virtual methods are
invoked in the base class's destructor. It is not safe to call virtual
methods in base's dtor.